package com.prs.crm.action.receipt;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.receipt.ReceiptFlowType;
import com.prs.crm.service.receipt.ReceiptFlowTypeService;

public class ReceiptFlowTypeAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private ReceiptFlowType receiptFlowType;
	private ReceiptFlowTypeService receiptFlowTypeService;
	private Integer[] ids;
	private PaginationSupport pagination;
	public ReceiptFlowType getReceiptFlowType() {
		return receiptFlowType;
	}
	public void setReceiptFlowType(ReceiptFlowType receiptFlowType) {
		this.receiptFlowType = receiptFlowType;
	}
	public ReceiptFlowTypeService getReceiptFlowTypeService() {
		return receiptFlowTypeService;
	}
	public void setReceiptFlowTypeService(
			ReceiptFlowTypeService receiptFlowTypeService) {
		this.receiptFlowTypeService = receiptFlowTypeService;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	@Action("listReceiptFlowType")
	public String listReceiptFlowType(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(ReceiptFlowType.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getReceiptFlowTypeService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("editReceiptFlowType")
	public String editReceiptFlowType(){
		return SUCCESS;
	}
	
	@Action(value="saveReceiptFlowType",results={
			@Result(name="success",type="redirect",location="listReceiptFlowType"),
			@Result(name="error",type="chain",location="editReceiptFlowType")
	})
	public String saveReceiptFlowType(){
		this.getReceiptFlowTypeService().save(receiptFlowType);
		return SUCCESS;
	}
	
	@Action(value="removeReceiptFlowType",results={
			@Result(name="success",type="redirect",location="listReceiptFlowType"),
			@Result(name="error",type="chain",location="listReceiptFlowType")
	})
	public String removeReceiptFlowType(){
		if (ids==null) {
			this.addActionError("请选择一行！");
			return ERROR;
		}
		this.getReceiptFlowTypeService().batchRemove(ids);
		return SUCCESS;
	}
}
